// miniprogram/pages/detail/detail.js
const { nav,specific } = require('../../../config/sorts');
Page({

  /**
   * 页面的初始数据
   */
  data: {
    activeNavIndex: 0,
    showNav: [],
    spec : []
  },
  changeShows(e) {
    console.log(e,"------");
    let {index, owntype} = e.currentTarget.dataset;
    let specific1 = specific.filter((spec1) => spec1.stype == owntype);
    this.setData({
      activeNavIndex: index,
      spec : specific1
    })
  },

  doShowChange(e) {
    console.log(e,'~~~~~');
    let index = e.detail.current;
    let owntype = index + 1;
    let id = wx.getStorageSync('id');
    let specific1 = specific.filter((spec1) => spec1.stype == owntype && spec1.cid==id);
    this.setData({
      activeNavIndex: index, /* 滑动的时候，上面的对应页页相应地变化 */
      spec: specific1
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let id = options.cid;
    wx.setStorageSync('id', id);
    let shows = nav.filter((show) => show.type == id); 
    let specific1 = specific.filter((spec1) => spec1.stype == "1");
    wx.showLoading({
      title: '小破站正疯狂加载中',
    })
    setTimeout(() => {
      wx.hideLoading({
        success: (res) => {},
      })
      this.setData({
        showNav: shows,
        spec : specific1
        // allHero: heroList,
        // heroList: heroList // 点击某个分类的子数据，怎么分离出来呢,即切换tab的时候怎么进行数据变化呢？
      })
    },1000)
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})